<?php
require 'include.php';
$q = "select infos.titre as titre,corps, concat(prenom,' ',nom) as auteur, datetime from infos inner join membres on (infos.membre_id = membres.id) where datetime like concat(date_sub(curdate(),interval 1 day),'%') and infos.valide = 1";
$r = ExecRequete($q);
$content = "
			<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='fr' lang='fr'>
			<head>
			<meta http-equiv='content-type' content='text/html; charset=iso-8859-1' />
			<link rel='stylesheet' href='http://www.vbcll.ch/styles/vbcll.css' type = 'text/css' />
			</head><body style = 'background-color: #FFF;'><div id = 'container' style = 'background-color: #FFF;'><div id = 'body' style = 'background-color: #FFF; text-align: justify;'>
";
$title = "VBCLL Infos : ";
$ok = 0;
while($s = LigneSuivante($r)){
	$ok = 1;
	$title .= "$s->titre &";
	$content .= "<h1>$s->titre</h1>\n";
	$content .= "<p class = 'fade'>Par $s->auteur (".(format_date($s->datetime)).")</p>\n";
	$content .= prepare_info($s->corps);
	$content .= "<p style = 'line-height: 3em;'>&nbsp;</p>\n";
}
if($ok){
	$q = "select email from membres where valide = 1 and fictif = 0 and lettre_info = 1 and email like '%@%'";
	$r = ExecRequete($q);
	$bcc = "";
	while($s = LigneSuivante($r)) $bcc .= "$s->email,";
	$bcc = ($bcc) ? substr($bcc,0,-1) : $bcc;
	$title = substr($title,0,-1);
	$content .= "</div></div></body></html>";
	$from = "info@vbcll.ch";
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
	$headers .= 'Bcc: ' . $bcc . "\r\n";
	$headers .= 'From: VBCLL <'.$from.">\r\n";
 	$to = "lettre_info@vbcll.ch";
	mail($to,utf8_encode($title),utf8_encode($content),$headers);		
}
?>
